<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>公告 - 听到微笑的博客</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/style.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/font-awesome.min.css">
<link rel="apple-touch-icon-precomposed" href="${pageContext.request.contextPath }/images/icon/icon.png">
<link rel="shortcut icon" href="${pageContext.request.contextPath }/images/icon/favicon.ico">
<script src="${pageContext.request.contextPath }/js/jquery-2.1.4.min.js"></script>
</head>
<body class="user-select">
	<section class="container-fluid">
		<jsp:include page="common/top.jsp"></jsp:include>
		<div class="row">
			<jsp:include page="common/left.jsp"></jsp:include>
			<div class="col-sm-9 col-sm-offset-3 col-md-10 col-lg-10 col-md-offset-2 main" id="main">
				<h1 class="page-header">操作</h1>
				<ol class="breadcrumb">
					<li>
						<a href="add-notice.html">增加公告</a>
					</li>
				</ol>
				<h1 class="page-header">管理</h1>
				<div class="table-responsive">
					<table class="table table-striped table-hover">
						<thead>
							<tr>
								<th>
									<span class="glyphicon glyphicon-th-large"></span>
									<span class="visible-lg">选择</span>
								</th>
								<th>
									<span class="glyphicon glyphicon-file"></span>
									<span class="visible-lg">标题</span>
								</th>
								<th>
									<span class="glyphicon glyphicon-time"></span>
									<span class="visible-lg">更新日期</span>
								</th>
								<th>
									<span class="glyphicon glyphicon-sort"></span>
									<span class="visible-lg">公告等级</span>
								</th>
								<th>
									<span class="glyphicon glyphicon-time"></span>
									<span class="visible-lg">是否有效</span>
								</th>
								<th>
									<span class="glyphicon glyphicon-pencil"></span>
									<span class="visible-lg">操作</span>
								</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${pageView.items }" var="item">
								<tr>
									<td>
										<input type="checkbox" class="input-control" name="checkbox[]" value="" />
									</td>
									<td class="article-title">${item.briefTitle }</td>
									<td>${item.stringUpdatetime }</td>
									<td>${item.level }</td>
									<c:choose>
										<c:when test="${item.tab==1 }">
											<td>是</td>
										</c:when>
										<c:otherwise>
											<td>否</td>
										</c:otherwise>
									</c:choose>
									<td>
										<a href="${pageContext.request.contextPath }/notice/update/${item.id}.html">修改</a>
										<c:choose>
											<c:when test="${item.tab==1 }">
												<a rel="6" onclick="activateNotice(${item.id},0)">作废</a>
											</c:when>
											<c:otherwise>
												<a rel="6" onclick="activateNotice(${item.id},1)">激活</a>
											</c:otherwise>
										</c:choose>
										<a rel="6" onclick="deleteNotice(${item.id})">删除</a>
									</td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
				</div>
				<footer class="message_footer">
					<nav>
						<div class="btn-toolbar operation" role="toolbar">
							<div class="btn-group" role="group">
								<a class="btn btn-default" onClick="select()">全选</a>
								<a class="btn btn-default" onClick="reverse()">反选</a>
								<a class="btn btn-default" onClick="noselect()">不选</a>
							</div>
							<div class="btn-group" role="group">
								<button type="submit" class="btn btn-default" data-toggle="tooltip" data-placement="bottom" title="删除全部选中" name="checkbox_delete">删除</button>
							</div>
						</div>
						<ul class="pagination pagenav">
							<c:choose>
								<c:when test="${pageView.currentPage>1 }">
									<li>
										<a aria-label="Previous" href="${pageContext.request.contextPath }/notice.html?currentPage=${pageView.currentPage-1}&countItem=${pageView.countItem}">
											<span aria-hidden="true">&laquo;</span>
										</a>
									</li>
								</c:when>
								<c:otherwise>
									<li class="disabled">
										<a aria-label="Previous">
											<span aria-hidden="true">&laquo;</span>
										</a>
									</li>
								</c:otherwise>
							</c:choose>
							<c:choose>
								<c:when test="${pageView.countPage>5 }">
									<c:choose>
										<c:when test="${pageView.currentPage>3 and pageView.currentPage<pageView.countPage-2 }">
											<li>
												<a href="#">...</a>
											</li>
											<c:forEach begin="${pageView.currentPage-2 }" end="${pageView.currentPage+2 }" var="i">
												<c:choose>
													<c:when test="${i==pageView.currentPage }">
														<li class="active">
															<a href="#">${i }</a>
														</li>
													</c:when>
													<c:otherwise>
														<li>
															<a href="${pageContext.request.contextPath }/notice.html?currentPage=${i}&countItem=${pageView.countItem}">${i }</a>
														</li>
													</c:otherwise>
												</c:choose>
											</c:forEach>
											<li>
												<a href="#">...</a>
											</li>
										</c:when>
										<c:when test="${pageView.currentPage<=3}">
											<c:forEach begin="1" end="5" var="i">
												<c:choose>
													<c:when test="${i==pageView.currentPage }">
														<li class="active">
															<a href="#">${i }</a>
														</li>
													</c:when>
													<c:otherwise>
														<li>
															<a href="${pageContext.request.contextPath }/notice.html?currentPage=${i}&countItem=${pageView.countItem}">${i }</a>
														</li>
													</c:otherwise>
												</c:choose>
											</c:forEach>
											<li>
												<a href="#">...</a>
											</li>
										</c:when>
										<c:when test="${pageView.currentPage>=pageView.countPage-2}">
											<li>
												<a href="#">...</a>
											</li>
											<c:forEach begin="${pageView.countPage-5 }" end="${pageView.countPage }" var="i">
												<c:choose>
													<c:when test="${i==pageView.currentPage }">
														<li class="active">
															<a href="#">${i }</a>
														</li>
													</c:when>
													<c:otherwise>
														<li>
															<a href="${pageContext.request.contextPath }/notice.html?currentPage=${i}&countItem=${pageView.countItem}">${i }</a>
														</li>
													</c:otherwise>
												</c:choose>
											</c:forEach>
										</c:when>
									</c:choose>
								</c:when>
								<c:otherwise>
									<c:forEach begin="1" end="${pageView.countPage }" var="i">
										<c:choose>
											<c:when test="${i==pageView.currentPage }">
												<li class="active">
													<a href="#">${i }</a>
												</li>
											</c:when>
											<c:otherwise>
												<li>
													<a href="${pageContext.request.contextPath }/notice.html?currentPage=${i}&countItem=${pageView.countItem}">${i }</a>
												</li>
											</c:otherwise>
										</c:choose>
									</c:forEach>
								</c:otherwise>
							</c:choose>
							<c:choose>
								<c:when test="${pageView.currentPage<pageView.countPage }">
									<li>
										<a href="${pageContext.request.contextPath }/notice.html?currentPage=${pageView.currentPage+1}&countItem=${pageView.countItem}" aria-label="Next">
											<span aria-hidden="true">&raquo;</span>
										</a>
									</li>
								</c:when>
								<c:otherwise>
									<li class="disabled">
										<a href="#" aria-label="Next">
											<span aria-hidden="true">&raquo;</span>
										</a>
									</li>
								</c:otherwise>
							</c:choose>
						</ul>
					</nav>
				</footer>
			</div>
		</div>
	</section>

	<script src="${pageContext.request.contextPath }/js/bootstrap.min.js"></script>
	<script src="${pageContext.request.contextPath }/js/admin-scripts.js"></script>
	<script>
		function deleteNotice(id) {
			if (window.confirm("此操作不可逆，是否确认？")) {
				$.ajax({
					type : "POST",
					url : "${pageContext.request.contextPath }/notice/delete/" + id + ".action",
					cache : false, //不缓存此页面   
					success : function(data) {
						window.location.reload();
					}
				});
			}
		}
	
		//用于发送激活（tab==1）或作废请求(tab==0)
		function activateNotice(id,tab) {
			$.ajax({
					type : "POST",
					url : "${pageContext.request.contextPath }/notice/activate/" + tab +"/"+id+ ".action",
					cache : false, //不缓存此页面   
					success : function(data) {
						window.location.reload();
					}
				});
		}
		$(function() {
			$("#notice").addClass('active');
		});
	</script>
</body>
</html>
